package com.bnq.logc.tmp

import com.bnq.logc.config.LogcConfig

object TmpFileUploadManager {

    fun init(configs: List<LogcConfig.TmpScheduleUploadFileConfig>?){
        configs?.forEach { config->
            init(config)
        }
    }

    fun init(config:LogcConfig.TmpScheduleUploadFileConfig){
        val scheduleUpload = TmpFileScheduleUpload(config)
        if(config.enabled){
            config.permissionCallback{ isGrant ->
                if(isGrant){
                    scheduleUpload.schedule(config.time,config.unit)
                }else{
                    scheduleUpload.cancel()
                }
            }
        }else{
            scheduleUpload.cancel()
        }
    }
}